﻿﻿using System;
using System.Collections.Generic;
using System.Web;
namespace BlackHtml5.WebSite.Web.Default.Common.Public
{
    public class KindEditorAction  : Controller
	{
		public KindEditorAction(System.IO.TextWriter tw):base(tw){}
		public KindEditorAction(string fileName) : base(fileName) {}
		public KindEditorAction(HttpContext context):base(context){}
		public KindEditorAction(Microsoft.Owin.IOwinContext context):base(context){}
        
        
        
        
        
		public void KindEditor()
        {
            
			Write("﻿");
			Write("\r\n<link rel=\"stylesheet\" href=\"");
			Write(_app);
			Write("/Content/kindeditor/themes/default/default.css\" />\r\n<link rel=\"stylesheet\" href=\"");
			Write(_app);
			Write("/Content/kindeditor/plugins/code/prettify.css\" />\r\n<script charset=\"utf-8\" src=\"");
			Write(_app);
			Write("/Content/kindeditor/kindeditor.js\"></script>\r\n<script charset=\"utf-8\" src=\"");
			Write(_app);
			Write("/Content/kindeditor/lang/zh_CN.js\"></script>\r\n<script charset=\"utf-8\" src=\"");
			Write(_app);
			Write("/Content/kindeditor/plugins/code/prettify.js\"></script>\r\n<script>\r\n    KindEditor.ready(function (K) {\r\n        K.create(\"textarea[data-type=\'kindeditor\']\", {\r\n            cssPath: \'");
			Write(_app);
			Write("/Content/kindeditor/plugins/code/prettify.css\',\r\n            uploadJson: \'");
			Write(_app);
			Write("/Content/kindeditor/asp.net/upload_json.ashx\',\r\n            fileManagerJson: \'");
			Write(_app);
			Write("/Content/kindeditor/asp.net/file_manager_json.ashx\',\r\n\t\t    allowFileManager: true\r\n\t\t});\r\n\t    prettyPrint();\r\n\t    K(\"input[data-type=\'upload-img\']\").each(function () {\r\n\t        var upload = K(this);\r\n\t        var img = K(this).attr(\'data-img\');\r\n\t        var input = K(this).attr(\'data-input\');\r\n\t        var uploadbutton = K.uploadbutton({\r\n\t            button: upload,\r\n\t            fieldName: \'imgFile\',\r\n\t            url: \'");
			Write(_app);
			Write("/Content/kindeditor/asp.net/upload_json.ashx\',\r\n\t            afterUpload: function (data) {\r\n\t                if (data.error === 0) {\r\n\t                    //alert(data.url);\r\n\t                    if (img != \"\") {\r\n\t                        K(\'#\' + img).attr(\'src\', data.url);\r\n\t                    }\r\n\t                    if (input != \"\") {\r\n\t                        K(\'#\' + input).val(data.url);\r\n\t                    }\r\n\t                } else {\r\n\t                    alert(data.message);\r\n\t                }\r\n\t            }\r\n\t        });\r\n\t        uploadbutton.fileBox.change(function (e) {\r\n\t            uploadbutton.submit();\r\n\t        });\r\n\t    });\r\n\t});\r\n</script>");
        }
        
    }
}